import {getHabit,getMessage, getSystemSetting} from "../utils/localStorageData";
import { baseMenuConfig, payAndIssueMenu} from "../config/menu";

const getters = {
  // base info
  token: state => state.user.token,
  TenantKey: state => state.user.TenantKey,
  userInfo: state => state.user.userInfo,
  systemSetting: state => state.setting.systemSetting,
  printSetting: state => state.setting.printSetting,
  checkTreatment:state => state.setting.checkTreatment,
  otherTreatment:state => state.setting.otherTreatment,
  messageList:state=> state.message.message,
  isNewOutpatien:state=> state.message.isNewOutpatien,
  isNewPay:state=>state.message.isNewPay,
  isNewDrug:state=>state.message.isNewDrug,
  isCharge:state=>state.message.isCharge,
  scanString: state=>state.scanCode.scanString,
  billCheck:state=>state.setting.billCheck,
  // order
  userHabit: state => {
    const habit = state.personalSt.habit
    // if (habit && habit.length) {
    //   return habit
    // } else {
    //   return getHabit()
    // }
    return getHabit()
  },
  menuConfig: state =>{
    let isIssue = true;
    if (state.setting.systemSetting.dic_value){
      isIssue = JSON.parse(state.setting.systemSetting.dic_value).charge_dispensing_management.function_set
    }

    let list = [];
    if (state.user.userInfo.menus){
      for (let i = 0; i < state.user.userInfo.menus.length; i++){
        if (state.user.userInfo.menus[i].code == "charge"){
          if (!isIssue){
            state.user.userInfo.menus[i].title = "收费/发药";
          }
        }
        list.push(state.user.userInfo.menus[i]);
      }
    }

    return list;
  }
}

export default getters
